package ch7.ex9;

import ch7.rand.*;
import static ch7.print.Print.*;
import java.util.*;

class Rodent{
	private String name = "Rodent";
	protected void eat(){
		println("Rodent.eat()");
	}
	protected void run(){
		println("Rodent.eat()");
	}
	protected void sleep(){
		println("Rodent.sleep()");
	}
	public String toString(){
		return name;
	}
}

class Mouse extends Rodent{
	private String name = "Mouse";
	protected void eat(){
		println("Mouse.eat()");
	}
	protected void run(){
		println("Mouse.run()");
	}
	protected void sleep(){
		println("Mouse.sleep()");
	}
	public String toString(){
		return name;
	}
}

class Hamster extends Rodent{
	private String name = "Hamster";
	protected void eat(){
		println("Hamster.eat()");
	}
	protected void run(){
		println("Hamster.run()");
	}
	protected void sleep(){
		println("Hamster.sleep()");
	}
	public String toString(){
		return name;
	}
}

class Gerbile extends Rodent{
	private String name = "Gerbile";
	protected void eat(){
		println("Gerbile.eat()");
	}
	protected void run(){
		println("Gerbile.run()");
	}
	protected void sleep(){
		println("Gerbile.sleep()");
	}
	public String toString(){
		return name;
	}
}

public class RodentTest {
	private static Rodent tt;

	public static void main(String... args){
		Rodent[] r = {
				new Gerbile(),
				new Hamster(),
				new Mouse()
		};
		RandomGenerator rr = new RandomGenerator();
		for(int i = 0; i < 200; i++){
			tt =  (Rodent)rr.next(r);
			println(tt);
			tt.eat();
			tt.run();
			tt.sleep();
		}
		}
}